<template>
  <div class="register-container">
    <h2>注册账号</h2>
    <div class="form-group">
      <label for="username">用户名:</label>
      <input type="text" id="username" name="username" required onfocus="userchongfu()" onblur="userchongfu()">
      <div id="username-error" style="display: none">
        <span style="color: red">用户名已存在</span>
      </div>
    </div>
    <div class="form-group">
      <label for="password">密码:</label>
      <input type="password" id="password" name="password" required>
    </div>
    <div class="form-group">
      <label for="confirm-password">确认密码:</label>
      <input type="password" id="confirm-password" name="confirm-password" required onfocus="validateForm()"
             onblur="validateForm()">
      <div id="password-error" style="display: none">
        <span style="color: red">两次密码不一致</span>
      </div>
    </div>
    <div class="login-link">
      <router-link to="/">已有账号？前往登录</router-link>
    </div>
    <button id="submit" class="submit-btn">注册</button>
  </div>
</template>

<script>
export default {
  name: "register",
  data(){
    return {
    }
  },
  methods:{}
}
</script>

<style scoped>
.register-container {
  background-color: white;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

h2 {
  text-align: center;
  margin-bottom: 30px;
  color: #333;
  font-weight: 500;
}

.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #555;
  font-weight: 500;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
  transition: border-color 0.3s;
}

input[type="text"]:focus, input[type="password"]:focus {
  border-color: #4a90e2;
  outline: none;
}

.login-link {
  text-align: center;
  margin-bottom: 20px;
}

.login-link a {
  color: #4a90e2;
  text-decoration: none;
  font-size: 14px;
}

.login-link a:hover {
  text-decoration: underline;
}

.submit-btn {
  width: 100%;
  padding: 12px;
  background-color: #4a90e2;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.submit-btn:hover {
  background-color: #357abd;
}

.error-message {
  color: #e74c3c;
  font-size: 14px;
  margin-top: 5px;
  display: none;
}
</style>